﻿using System;
using System.Collections.Generic;
using System.Text;
using Entities;
using DAL;
using System.Data.SqlClient;

namespace BUS
{
    public class tbTTDonHangBus
    {
        public static void Insert_ChuDe(tbTTDonHang ttdonhang)
        {
            tbTTDonHangDAL ttdonhangDAL = new tbTTDonHangDAL();
            ttdonhangDAL.Insert(ttdonhang);
        }
        public static void Update_ChuDe(tbTTDonHang ttdonhang)
        {
            tbTTDonHangDAL ttdonhangDAL = new tbTTDonHangDAL();
            ttdonhangDAL.Update(ttdonhang);
        }
        public static void Delete_ChuDe(int Id)
        {
            tbTTDonHangDAL ttdonhangDAL = new tbTTDonHangDAL();
            ttdonhangDAL.Delete(Id);
        }
        public static tbTTDonHang.tbTTDonHangCollection Get(string Where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {

            tbTTDonHangDAL ttdonhangDAL = new tbTTDonHangDAL();
            return (ttdonhangDAL.Get(Where, pageindex, pagesize, orderby, orderdirection, out total));
        }
        public static tbTTDonHang.tbTTDonHangCollection GetAll()
        {
            int total = 0;
            tbTTDonHangDAL ttdonhangDAL = new tbTTDonHangDAL();
            return ttdonhangDAL.Get("Where 1=1", 0, 0, tbTTDonHang.tbTTDonHangColumns.IDTTDonHang.ToString(), "ASC", out total);
        }
        public static tbTTDonHang GetByID(int iD)
        {
            int total = 0;
            tbTTDonHangDAL ttdonhangDAL = new tbTTDonHangDAL();
            tbTTDonHang.tbTTDonHangCollection ttdonhangcollection = ttdonhangDAL.Get("where " + tbTTDonHang.tbTTDonHangColumns.IDTTDonHang.ToString() + "=" + iD.ToString(), 0, 0, tbTTDonHang.tbTTDonHangColumns.IDTTDonHang.ToString(), "ASC", out total);
            if (ttdonhangcollection.Count > 0)
                return ttdonhangcollection[0];
            return null;
        }

    } 
}
